<script type="text/javascript">
    $(function() {        
        $("a.back").button({
            icons: {
                primary: "ui-icon-circle-arrow-w"
            }
        });
        $("input:submit").button({
            icons: {
                primary: "ui-icon-disk"
            }
        });
        
        $(".ac_input").autocomplete({
            source: "<?php echo url_for('category_get_candidates', $category)?>",
            minLength: 1,
            focus: function( event, ui ) {
                $( "#nominee_autocomplete_input" ).val( ui.item.label );
                return false;
            },
            select: function( event, ui ) {
                $('#nominee_autocomplete_input').val(ui.item.label);
                $('#nominee_candidate_id').val(ui.item.value);
                return false;
            },
            open: function() {
                $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
            },
            close: function() {
                $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
            }
        }).data( "autocomplete" )._renderItem = function( ul, item ) {
            var desc = item.desc.length <= 120 ? item.desc : item.desc.substr(0, 120)+"...";
            var height_adjust = desc.length > 70 ? "style=\"height:60px;\"" : "";
            return $( "<li class='ac_option'></li>" )
                .data( "item.autocomplete", item )
                .append( "<a "+height_adjust+"><ul><li><span class='ac_option_image' style='background: url(/uploads/"+item.icon+") no-repeat'></li></span><li><span class='ac_option_info'>" + item.label + "<br><em class='small'>" + desc + "</em></span></li></ul></a>")
                .appendTo( ul );
        };
    });
</script>
<h1>Nominando a la categoria: <?php echo $category?></h1>
<form action="<?php echo url_for('category_add_nominee', $category)?>" method="post">
    <?php if (!$form->getObject()->isNew()): ?>
        <input type="hidden" name="sf_method" value="put" />
    <?php endif; ?>
    <table>
        <tfoot>
            <tr>
                <td>&nbsp;<input type="submit" value="Guardar" /></td>
            </tr>
            <tr>
                <td>&nbsp;<a class="back" href="<?php echo url_for('category_nominees', $category) ?>">Regresar</a></td>
            </tr>
        </tfoot>
        <tbody>
            <?php echo $form ?>
        </tbody>
    </table>
</form>